import pandas as pd

data = {
    "Name": ["Alice", "Bob", "Tom", "Jerry", "David"],
    "Age": [22, 23, 24, 25, 26],
    "City": ["Beijing", "Shanghai", "Guangzhou", "Shenzhen", "Hangzhou"],
}
df = pd.DataFrame(data)

# 基本方法
print("index:", df.index)
print("columns列名:", df.columns)
print("shape:", df.shape)
""" 
index: RangeIndex(start=0, stop=5, step=1
columns列名: Index(['Name', 'Age', 'City'], dtype='object')
shape: (5, 3)
"""
print("head\n", df.head(2))
print("tail\n", df.tail(2))


print("info 列名、数据类型、非空值数量:\n", df.info())
""" 
RangeIndex: 5 entries, 0 to 4
Data columns (total 3 columns):
 #   Column  Non-Null Count  Dtype 
---  ------  --------------  ----- 
 0   Name    5 non-null      object
 1   Age     5 non-null      int64 
 2   City    5 non-null      object
dtypes: int64(1), object(2)
memory usage: 248.0+ bytes
info:  None
"""

print("describe 均值、标准差、最小值:\n", df.describe())
""" 
              Age
count   5.000000
mean   24.000000
std     1.581139
min    22.000000
25%    23.000000
50%    24.000000
75%    25.000000
max    26.000000
"""
